package models
{
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	import mx.containers.Panel;
	import mx.containers.VBox;
	import mx.containers.ViewStack;
	import mx.controls.LinkButton;
	import mx.effects.Fade;
	import mx.effects.Parallel;
	import mx.effects.Resize;

	public class GroupeResisable extends VBox
	{
		private var panelInformations:Panel;
		private var bOpenClose:LinkButton;
		private var viewstack:ViewStack;
		private var canvasEmpty:Canvas;
		
		public function GroupeResisable(value:String)
		{
			super();
			
			var effectResize:Resize = new Resize();
			effectResize.duration = 1200;
			var effectFade:Fade = new Fade();
			effectFade.duration = 1200;
			
			var para:Parallel = new Parallel(viewstack);
			para.addChild(effectResize);
			para.addChild(effectFade);
			
			bOpenClose = new LinkButton;
			bOpenClose.label = value;
			bOpenClose.addEventListener(MouseEvent.CLICK,openOrClose);
			
			viewstack= new ViewStack();
			viewstack.resizeToContent = true;
			viewstack.setStyle("resizeEffect",effectResize);
			
			
			panelInformations = new  Panel();
			panelInformations.horizontalScrollPolicy="off";
			panelInformations.verticalScrollPolicy="off";
			panelInformations.setStyle("hideEffect",effectResize);
			
			canvasEmpty = new Canvas();
			canvasEmpty.height = 0;
			canvasEmpty.width = 0;

			
			this.addChild(bOpenClose);
			viewstack.addChild(canvasEmpty);
			viewstack.addChild(panelInformations);
			this.addChild(viewstack);
		}
		
		public function openOrClose(event:MouseEvent):void{
			
			if(viewstack.selectedChild == canvasEmpty){
				viewstack.selectedChild = panelInformations;
			}
			else{
				viewstack.selectedChild = canvasEmpty;
				viewstack.resizeToContent = true;
			}
		}
		
		public function get panelInfo():Panel{
			return panelInformations;
		}

		
	}
}